package controller;

import moder.TbUser;
import java.io.IOException;
import java.util.UUID;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/reg.do")
public class RegesitController extends HttpServlet {
    service.TbUserService us = new service.impl.TbUserServiceImpl();
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setHeader("Content-Type", "text/html; charset=UTF-8");

        String uid = UUID.randomUUID().toString();
        String username = request.getParameter("username");
        String upassword = request.getParameter("password");
        String uemail = request.getParameter("email");
        //封装成 TbUser对象;
        TbUser user = new TbUser(uid, username, upassword, null, uemail, null, null, null, 0);
        us.insertUserreg(user);

        request.getRequestDispatcher("/secess.jsp").forward(request, response);

    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

}

